package org.darkforest.common.services.impl;

import org.apache.commons.lang3.StringUtils;
import org.darkforest.common.services.BusinessPropertiesService;
import org.darkforest.dao.mapper.PropertiesMapper;
import org.darkforest.model.BusinessProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * BusinessPropertyServiceImpl
 * Created by Justin on 15/5/23.
 */
@Service
public class BusinessPropertyServiceImpl implements BusinessPropertiesService {

    @Autowired
    private PropertiesMapper mapper;

    @Override
    public void setProperty(String key, String value) {
        mapper.set(new BusinessProperty(key, value));
    }

    @Override
    public String getProperty(String key) {
        BusinessProperty property = mapper.get(key);
        return property == null ? StringUtils.EMPTY : property.getpValue();
    }
}
